package top.chj.day16.dateclass;

import org.junit.Test;

import java.sql.Timestamp;
import java.time.*;
import java.util.Date;

/**
 * @Auther:小陈的Java
 */
public class DateChangeDemo {
    @Test
    public void method1(){
        Date date = new Date();
        Instant instant = date.toInstant();
        ZonedDateTime zonedDateTime = instant.atZone(ZoneId.systemDefault());
        LocalDate localDate = zonedDateTime.toLocalDate();
        System.out.println(localDate);
    }
    @Test
    public void method2(){
        java.sql.Date date = new java.sql.Date(System.currentTimeMillis());
        System.out.println(date);
        LocalDate localDate = date.toLocalDate();
        System.out.println(localDate);
        java.sql.Date date1 = java.sql.Date.valueOf(localDate);
        System.out.println(date1);
    }
    @Test
    public void method3(){
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        System.out.println(timestamp);
        LocalDateTime localDateTime =timestamp.toLocalDateTime();
        System.out.println(localDateTime);
        Timestamp timestamp1 = Timestamp.valueOf(localDateTime);
        System.out.println(timestamp1);
    }
}
